package org.zasadnyy.redlions.players.client.ui;

import com.smartgwt.client.widgets.Img;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.events.MouseOutEvent;
import com.smartgwt.client.widgets.events.MouseOutHandler;
import com.smartgwt.client.widgets.events.MouseOverEvent;
import com.smartgwt.client.widgets.events.MouseOverHandler;
import com.smartgwt.client.widgets.layout.HStack;

public class EditToolsStack extends HStack {

	private Img editPlayers;
	private Img listPlayers;

	public EditToolsStack() {
		super();
		initLayout();
	}

	private void initLayout() {
		setMembersMargin(5);
		setBackgroundColor("transparent");

		editPlayers = new Img("img/edit.png");
		editPlayers.setOpacity(40);
		editPlayers.setHeight(16);
		editPlayers.setWidth(16);
		editPlayers.addMouseOverHandler(new MouseOverHandler() {

			@Override
			public void onMouseOver(MouseOverEvent event) {
				editPlayers.setOpacity(100);
			}
		});
		editPlayers.addMouseOutHandler(new MouseOutHandler() {

			@Override
			public void onMouseOut(MouseOutEvent event) {
				editPlayers.setOpacity(40);
			}
		});

		addMember(editPlayers);

		listPlayers = new Img("img/list.png");
		listPlayers.setOpacity(40);
		listPlayers.setHeight(16);
		listPlayers.setWidth(16);
		listPlayers.addMouseOverHandler(new MouseOverHandler() {

			@Override
			public void onMouseOver(MouseOverEvent event) {
				listPlayers.setOpacity(100);
			}
		});
		listPlayers.addMouseOutHandler(new MouseOutHandler() {

			@Override
			public void onMouseOut(MouseOutEvent event) {
				listPlayers.setOpacity(40);
			}
		});

		addMember(listPlayers);
	}

	public void addListClickHandler(ClickHandler handler) {
		listPlayers.addClickHandler(handler);
	}
	
	public void addEditClickHandler(ClickHandler handler) {
		editPlayers.addClickHandler(handler);
	}
}
